package it.gat.controller;

import java.util.Arrays;
import java.util.List;

import it.gat.controller.resource.ResourceFactory;
import it.gat.model.Operatore;
import it.gat.model.Ticket;
import it.gat.model.Cliente;
import it.gat.webservice.string.Resource;

public class TicketController {
	
	public Ticket getTicket(String codice)
	{
		return ResourceFactory.get(Resource.TICKET,codice,Ticket.class); 
	}
	
	public List<Ticket> getTicketList()
	{
		return Arrays.asList(ResourceFactory.get(Resource.TICKET,Resource.LISTAURI,Ticket[].class));
	}
	
	public List<Ticket> getTicketApertiList()
	{
		return Arrays.asList(ResourceFactory.get(Resource.TICKETAPERTI,Resource.LISTAURI,Ticket[].class));
	}
	
	public List<Ticket> getTicketAssegnatiList()
	{
		return Arrays.asList(ResourceFactory.get(Resource.TICKETASSEGNATI,Resource.LISTAURI,Ticket[].class));
	}
	
	public void insertTicket(Ticket ticket)
	{
		ResourceFactory.post(Resource.TICKET, ticket,Ticket.class);
	}
	
	public void updateTicket(Ticket ticket)
	{
		ResourceFactory.put(Resource.TICKET, ticket.getIdTicket(),ticket);
	}
	
	public void deleteTicket(String codice)
	{
		ResourceFactory.delete(Resource.TICKET,codice);
	}

	public List<Ticket> getTicketCliente(Cliente cliente) {
		return Arrays.asList(ResourceFactory.get(Resource.TICKETCLIENTE,cliente.getIdCliente(),Ticket[].class));
	}
	
	public List<Ticket> getTicketTecnico(Operatore tecnico) {
		return Arrays.asList(ResourceFactory.get(Resource.TICKETTECNICO,tecnico.getNomeUtente(),Ticket[].class));
	}

}
